package main

import "fmt"

func main() {
	//1 指针与地址
	m := 99
	var ptr *int = &m
	fmt.Printf("ptr指向的值为%v\n", *ptr)
	fmt.Printf("ptr的地址为%v\n", &ptr)
	fmt.Printf("m的地址为%v\n", &m)

	//2 输入
	var name string
	var age byte
	var sale float32
	fmt.Println("input name:")
	fmt.Scanln(&name)
	fmt.Println("input age:")
	fmt.Scanln(&age)
	fmt.Printf("your input name is %v age is %v\n", name, age)

	fmt.Println("please input name age sale:")
	fmt.Scanf("your input is :%s %d %f", &name, &age, &sale)
	fmt.Printf("your input name is %v age is %v\n", name, age)

	//3 if 语句
	if num := 99; num > 70 {
		fmt.Println("num larger than 70")
	}

	//4 switch 默认break,fallthrough强制执行后面的case代码
	s := 3
	switch s {
	case 1:
		fmt.Println("s is 1")
	case 2:
		fmt.Println("s is 2")
	case 3, 5: //多表达式
		fmt.Println("s is 3 or 5")
		fallthrough
	case 99:
		fmt.Println("s larger than 2")
	default:
		fmt.Println("s unknown")
	}
	//switch后无表达式
	switch {
	case s == 1:
		fmt.Println("s is 1")
	case s == 3:
		fmt.Println()
	}

	//5 for
	i := 12
	for i > 10 {
		fmt.Println("i larger than 10")
		break
	}

	//6 for range
	var arr = [3]int{1, 2, 3}
	for index, value := range arr {
		fmt.Printf("index is %v,value is %v", index, value)
	}
}
